<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html>
<html lang="ko">
<head>
	<%@ include file="/include/header.jsp" %>
	<link rel="stylesheet" href="<%=cp %>/css/board.css">
	<%@ include file="/include/commonRes.jsp" %>
	
	<script type="text/javascript">
	$(function(){
		$("#submitLink").click(function(){
			
			$("#editForm").submit();
			return false;
		});
		
	});
	function save(){
		if(!validate()) {
			return false;
		} else {
			if(!confirm("저장 하시겠습니까?")){
				return false;
			}
			
			return true;
		}
	}
	function validate(){
		var boardCode=$("#boardCode");
		var boardTitle=$("#boardTitle");
		var boardContents=$("#boardContents");
		
		var boardCode_val=boardCode.val();
		var boardTitle_val=boardTitle.val();
		var boardContents_val=boardContents.val();
		
		
		
		if(boardCode_val==null || boardCode_val==""){
			alert("게시판 구분을 선택해주세요.");
			return false;
		}
		if(boardTitle_val==null || boardTitle_val==""){
			alert("제목을 입력해주세요.");
			return false;
		}
		
		if(getBytes(boardTitle_val)>255) {
			alert("제목의 글자수가 허용범위를 초과했습니다.");
			return false;
		}
		
		if(boardContents_val==null || boardContents_val==""){
			alert("본문 내용을 입력해주세요.");
			return false;
		}
		
		if(getBytes(boardContents_val)>2147500000) {
			alert("내용의 글자수가 허용범위를 초과했습니다.");
			return false;
		}
		return true;
		
	}
	</script>
</head>
<body>
	<%@include file="/include/mainMenuHeader.jsp" %>
	
	
	<div id="wrapper">
		<div id="container">
			<script src="<%=cp%>/js/viewimageresize.js"></script>
			<!--  <div id="bo_v_table">&nbsp;</div>-->
			<form action="<%=cp%>/bbs/notice_edit.do" method="post" id="editForm" name="editForm" onsubmit="return save();">
				<input type="hidden" name="boardSeq" value="${bbs.boardSeq }"/>
				<article id="bo_v" style="width:100%">
				    <header>
			        	<h2>공지사항</h2>
				    </header>
				
				    <section>&nbsp;</section>
				    
				    <div class="tbl_head01 tbl_wrap">
				        <div class="notice_li_table_view">
							<section>&nbsp;</section>
							
							<input type="hidden"  id="mode" name="mode" value="${mode }"/> 
							<ul>
								<li class="title">게시판 구분</li>
								<li class="content first">
									<select name="boardCode" id="boardCode">
										<option value="">선택</option>
										<option value="1" <c:if test="${bbs.boardCode==1 }">selected</c:if>>공고</option>
										<option value="2" <c:if test="${bbs.boardCode==2 }">selected</c:if>>병원관련</option>
										<option value="3" <c:if test="${bbs.boardCode==3 }">selected</c:if>>진료관련</option>
										<option value="4" <c:if test="${bbs.boardCode==4 }">selected</c:if>>아이디어</option>
									</select>
								</li>
							</ul>
							<ul>
								<li class="title">제목</li>
								<li class="content">
									<input type="text" id="boardTitle" name="boardTitle" value="${bbs.boardTitle}" class="size_50per" />
								</li>
							</ul>
							<ul>
								<li class="title end endH1">본문</li>
								<li class="content endH2">
									<textarea id="boardContents" name="boardContents" rows="5" cols="10" class="size_50per h70">${bbs.boardContents}</textarea>
								</li>
							</ul>
						</div>
					</div>
					<section>&nbsp;</section>
				    <div id="bo_v_bot">
				        <!-- 링크 버튼 -->
				        
				        <ul class="bo_v_com">
				            <c:if test="${sessionScope.ss_mb.mb_auth_code==7 || sessionScope.ss_mb.mb_auth_code==8}">
				            	<li>
					            	<c:if test="${mode=='insert' }">
										<a href="#" class="btn_b01" id="submitLink">등록</a>
									</c:if>
									<c:if test="${mode=='update' }">
										<a href="#" class="btn_b01" id="submitLink">수정</a>
									</c:if>
				            	</li>
				            </c:if>
			            	<li><a href="#" class="btn_b01" onclick="history.back();">취소</a></li>
				        </ul>
			    	</div>
				</article>
			</form>
		</div>
	</div>
	<%@ include file="/include/footer.jsp" %>
</body>
</html>